﻿namespace ElisVK.Controls
{
    using System.Windows;
    using System.Windows.Controls;

    public class CommandLink : Button
    {
        public static readonly DependencyProperty DescriptionProperty;

        static CommandLink()
        {
            DefaultStyleKeyProperty.OverrideMetadata(
                typeof(CommandLink), new FrameworkPropertyMetadata(typeof(CommandLink)));

            DescriptionProperty = DependencyProperty.Register(
                "Description", typeof(object), typeof(CommandLink), new PropertyMetadata(OnDescriptionPropertyChanged));
        }

        public object Description
        {
            get
            {
                return GetValue(DescriptionProperty);
            }

            set
            {
                SetValue(DescriptionProperty, value);
            }
        }
    
        protected virtual void OnDescriptionChanged(DependencyPropertyChangedEventArgs eventArgs)
        {
        }
        
        private static void OnDescriptionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var cl = d as CommandLink;
            
            if (cl != null)
                cl.OnDescriptionChanged(e);
        }
    }
}
